package com.example.demo.controller;

import com.example.demo.entity.User;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("")
    public String userPage() {
        return ("user");
    }

    @RequestMapping("getUser")
    @ResponseBody
    public User getUser(String user_id) {
        return userService.getUserInfo(user_id);
    }

    @RequestMapping("register")
    @ResponseBody
    public int register(String user_name, String user_password, String user_telephone, String user_address, String user_mailbox) {
        return userService.register(user_name, user_password, user_telephone, user_address, user_mailbox);
    }

    @RequestMapping("loginStatus")
    @ResponseBody
    public int loginStatus(String user_telephone, String user_password) {
        return userService.loginStatus(user_telephone, user_password);
    }

    @RequestMapping("loginUser")
    @ResponseBody
    public User loginUser(String user_telephone) {
        return userService.loginUser(user_telephone);
    }

    @RequestMapping("modifyUser")
    @ResponseBody
    public int modifyUser(String user_id, String user_name, String user_password, String user_telephone, String user_address, String user_mailbox) {
        return userService.modifyUser(user_id, user_name, user_password, user_telephone, user_address, user_mailbox);
    }

}
